<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
        <%
	//检查会话中是否有 "admin" 属性
	Object fdyObj = session.getAttribute("admin");
	if (fdyObj == null) {
	    response.sendRedirect("Login.jsp");
	    return;
	}
%>  
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>管理员页面</title>
<link href="../css/Utils.css" rel="stylesheet" type="text/css" />
<link href="../css/List.css" rel="stylesheet" type="text/css" />
</head>
<body>

<!-- 头部 -->
<div class="header" ><br>
<nerong>&nbsp;&nbsp;管理员页面&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;</nerong>
<a bgc>退出登录</a>
</div>


<div class="left" >
<table width="80%" height="80%">
<th>
<nerong>管理员可选择内容</nerong>

</th>

<tr>
<td>
<a href="../View_Msg/msgAdmin.jsp">&emsp;个人信息</a><br>
</td>
</tr>

<tr>
<td>
<a href="../View_xx/XxStudent.jsp">&emsp;学生信息管理</a><br>
</td>
</tr>


<tr>
<td>
<a href="../View_xx/XxFdy.jsp">&emsp;辅导员信息管理</a><br>
</td>
</tr>

<tr>
<td>
<a href="../View_xx/XxSuGuan.jsp">&emsp;宿管信息管理</a><br>
</td>
</tr>

<tr>
<td>
<a href = "../View_xx/XxWy.jsp">&emsp;物业信息管理</a><br>
</td>
</tr>


<tr>
<td>
<a href = "../View_SuShe/SuSheAdminMain.jsp">&emsp;宿舍入住管理</a><br>
</td>
</tr>

</table>
</div>

<div class="context" > 

      <table class="Alltable" >
  <caption>辅导员信息</caption>
  <thead>
     <tr>
         <th>id</th>
         <th>姓名</th>
         <th>班级</th>
         <th>操作</th>

     </tr>
   </thead>
   <%
      String driverClass="com.mysql.cj.jdbc.Driver";
      String url="jdbc:mysql://localhost:3306/javaweb";
      String user="root";
      String password="aa5678989";
      Connection conn;
      try{
    	  Class.forName(driverClass);
     	 conn=DriverManager.getConnection(url, user, password);
     	 Statement stmt=conn.createStatement();
     	 String sql="select * from fdy";
     	 ResultSet rs=stmt.executeQuery(sql);
     	 while(rs.next()){

     
   %>
  <!--  连接数据库 -->
   <tbody align="center"  bgcolor="#ddd">
      <tr>
         <td><%=rs.getString("id") %></td>
         <td><%=rs.getString("name") %></td>
         <td><%=rs.getString("class") %></td>
	
		<td>
                   <button class="btn btn-green" onclick="window.location.href='XxFdy_edit.jsp?id=<%= rs.getString("id") %>&class=<%= rs.getString("class") %>'">
                				<i class="icon-eye"></i> 修改
                			</button>  
                     
                	<button class="btn btn-green" onclick="window.location.href='XxFdy_add.jsp?id=<%= rs.getString("id") %>'">
                				<i class="icon-eye"></i> 添加
                			</button> 
                			
                	 <form action="../XxFdyDeleteServlet" method="post">   
    					<!-- 隐藏输入字段 -->
    					<input type="hidden" name="id" value="<%=rs.getString("id") %>">
   					 	<!-- 提交按钮 -->
    					<button type="submit">删除</button>
					</form>		
					
                	<form action="../XxUserResetPwServlet" method="post">   
    					<!-- 隐藏输入字段 -->
    					<input type="hidden" name="id" value="<%=rs.getString("id") %>">
    					<input type="hidden" name="page" value=<%="2"%>>
   					 	<!-- 提交按钮 -->
    					<button type="submit">重置密码</button>
					</form>	
                </td>
            </tr>


         </tr>
         <% 
         }
      }catch(Exception ex){
    	  ex.printStackTrace();
      }
     	%>
    </tbody>   
    </table>
  
</body>
</html>